package com.shujia.wyh.day06;

/*
        二维数组遍历
 */
public class Array2Test1 {
    public static void main(String[] args) {
        //定义一个二维数组
        int[][] arr = {{1,2,3},{12,7},{11,22,33,44,55}};

        printTowArray(arr);




    }


    public static void printTowArray(int[][] arr){
        for (int i = 0; i < arr.length; i++) { //获取到二维数组中的每一个一维数组
            System.out.println("现在打印的是第" + (i + 1) + "个一维数组：");
            for (int j = 0; j < arr[i].length; j++) { //获取每一个一维数组中的元素
                if (j == 0) {
                    System.out.print("[" + arr[i][j] + ",");
                } else if (j == arr[i].length - 1) {
                    System.out.print(arr[i][j] + "]");
                } else {
                    System.out.print(arr[i][j] + ",");
                }

            }
            System.out.println();
        }
    }
}
